package com.yanfan.accessControl.service.impl;

import java.util.Arrays;
import java.util.List;

import com.yanfan.accessControl.domain.IbmsAccessControlDevice;
import com.yanfan.accessControl.domain.IbmsAccessFlow;
import com.yanfan.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.accessControl.mapper.IbmsAccessControlRecordsMapper;
import com.yanfan.accessControl.domain.IbmsAccessControlRecords;
import com.yanfan.accessControl.service.IIbmsAccessControlRecordsService;

/**
 * 门禁系统通行记录Service业务层处理
 *
 * @author genluo
 * @date 2024-09-23
 */
@Service
public class IbmsAccessControlRecordsServiceImpl extends ServiceImpl<IbmsAccessControlRecordsMapper, IbmsAccessControlRecords> implements IIbmsAccessControlRecordsService {
    @Autowired
    private IbmsAccessControlRecordsMapper ibmsAccessControlRecordsMapper;


    /**
     * 查询门禁系统通行记录列表
     *
     * @param ibmsAccessControlRecords 门禁系统通行记录
     * @return 门禁系统通行记录
     */
    @Override
    public List<IbmsAccessControlRecords> queryPageList(IbmsAccessControlRecords ibmsAccessControlRecords) {
        LambdaQueryWrapper<IbmsAccessControlRecords> lqw = buildQueryWrapper(ibmsAccessControlRecords);

        return ibmsAccessControlRecordsMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        //return ibmsAccessControlRecordsMapper.queryPageList(ibmsAccessControlRecords);
    }


    /**
     * 分页查询条件
     * @return
     */
    private LambdaQueryWrapper<IbmsAccessControlRecords> buildQueryWrapper(IbmsAccessControlRecords bo) {
        LambdaQueryWrapper<IbmsAccessControlRecords> lqw = Wrappers.lambdaQuery();
        lqw.eq(bo.getBodyTemperatureAlarm() != null, IbmsAccessControlRecords::getBodyTemperatureAlarm, bo.getBodyTemperatureAlarm());
        lqw.eq(bo.getCardType() != null, IbmsAccessControlRecords::getCardType, bo.getCardType());
        lqw.eq(bo.getDoorId() != null, IbmsAccessControlRecords::getDoorId, bo.getDoorId());
        lqw.like(StringUtils.isNotBlank(bo.getDoorName()), IbmsAccessControlRecords::getDoorName, bo.getDoorName());
        lqw.eq(bo.getDoorStatus() != null, IbmsAccessControlRecords::getDoorStatus, bo.getDoorStatus());
        lqw.eq(StringUtils.isNotBlank(bo.getEmployeeId()), IbmsAccessControlRecords::getEmployeeId, bo.getEmployeeId());
        lqw.like(StringUtils.isNotBlank(bo.getEmployeeName()), IbmsAccessControlRecords::getEmployeeName, bo.getEmployeeName());
        lqw.eq(bo.getEmployeeSysNo() != null, IbmsAccessControlRecords::getEmployeeSysNo, bo.getEmployeeSysNo());
        lqw.eq(bo.getEventDate() != null, IbmsAccessControlRecords::getEventDate, bo.getEventDate());
        lqw.eq(bo.getEventType() != null, IbmsAccessControlRecords::getEventType, bo.getEventType());
        lqw.eq(bo.getHistoryRecord() != null, IbmsAccessControlRecords::getHistoryRecord, bo.getHistoryRecord());
        lqw.eq(bo.getLiveness() != null, IbmsAccessControlRecords::getLiveness, bo.getLiveness());
        lqw.eq(bo.getMask() != null, IbmsAccessControlRecords::getMask, bo.getMask());
        lqw.like(StringUtils.isNotBlank(bo.getName()), IbmsAccessControlRecords::getName, bo.getName());
        lqw.eq(bo.getOperationLocator() != null, IbmsAccessControlRecords::getOperationLocator, bo.getOperationLocator());
        lqw.eq(bo.getPortrait() != null, IbmsAccessControlRecords::getPortrait, bo.getPortrait());
        lqw.eq(StringUtils.isNotBlank(bo.getSerial()), IbmsAccessControlRecords::getSerial, bo.getSerial());
        lqw.eq(bo.getSimilar() != null, IbmsAccessControlRecords::getSimilar, bo.getSimilar());
        lqw.eq(bo.getTemperature() != null, IbmsAccessControlRecords::getTemperature, bo.getTemperature());
        lqw.eq(StringUtils.isNotBlank(bo.getTypeDescribe()), IbmsAccessControlRecords::getTypeDescribe, bo.getTypeDescribe());
        lqw.like(StringUtils.isNotBlank(bo.getTypeName()), IbmsAccessControlRecords::getTypeName, bo.getTypeName());
        lqw.orderByDesc(IbmsAccessControlRecords :: getEventDate);
        lqw.eq(StringUtils.isNotBlank(bo.getIsBusiness()), IbmsAccessControlRecords::getIsBusiness, bo.getIsBusiness());
        return lqw;
    }



}
